[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
When you invoke GCC, it normally does preprocessing, compilation, assembly and linking. The "overall options" allow you to stop this process at an intermediate stage. For example, the `-c' option says not to run the linker. Then the output consists of object files output by the assembler.
Other options are passed on to one stage of processing. Some options control the preprocessor and others the compiler itself. Yet other options control the assembler and linker; most of these are not documented here, since you rarely need to use any of them.
Most of the command line options that you can use with GCC are useful for C programs; when an option is only useful with another language (usually C++), the explanation says so explicitly. If the description for a particular option does not mention a source language, you can use that option with all supported languages.
See section Compiling C++ Programs, for a summary of special options for compiling C++ programs.
The gcc
program accepts options and file names as operands. Many
options have multiletter names; therefore multiple single-letter options
may not be grouped: `-dr' is very different from `-d
-r'.
You can mix options and other arguments. For the most part, the order you use doesn't matter. Order does matter when you use several options of the same kind; for example, if you specify `-L' more than once, the directories are searched in the order specified.
Many options have long names starting with `-f' or with `-W'---for example, `-fforce-mem', `-fstrength-reduce', `-Wformat' and so on. Most of these have both positive and negative forms; the negative form of `-ffoo' would be `-fno-foo'. This manual documents only one of these two forms, whichever one is not the default.
2.1 Option Summary | Brief list of all options, without explanations. | |
2.2 Options Controlling the Kind of Output | Controlling the kind of output: an executable, object files, assembler files, or preprocessed source. | |
2.3 Compiling C++ Programs | Compiling C++ programs. | |
2.4 Options Controlling C Dialect | Controlling the variant of C language compiled. | |
2.5 Options Controlling C++ Dialect | Variations on C++. | |
2.6 Options to Request or Suppress Warnings | How picky should the compiler be? | |
2.7 Options for Debugging Your Program or GCC | Symbol tables, measurements, and debugging dumps. | |
2.8 Options That Control Optimization | How much optimization? | |
2.9 Options Controlling the Preprocessor | Controlling header files and macro definitions. Also, getting dependency information for Make. | |
2.10 Passing Options to the Assembler | Passing options to the assembler. | |
2.11 Options for Linking | Specifying libraries and so on. | |
2.12 Options for Directory Search | Where to find header files and libraries. Where to find the compiler executable files. | |
2.13 Specifying subprocesses and the switches to pass to them | How to pass switches to sub-processes. | |
2.14 Specifying Target Machine and Compiler Version | Running a cross-compiler, or an old version of GCC. | |
2.15 Different CPUs and Configurations | Specifying minor hardware or convention variations, such as r3000 vs r4000. | |
2.16 Options for Code Generation Conventions | Specifying conventions for function calls, data layout and register usage. | |
2.17 Environment Variables Affecting GCC | Env vars that affect GCC. | |
2.18 Running Protoize | Automatically adding or removing function prototypes. |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Here is a summary of all the options, grouped by type. Explanations are in the following sections.
-c -S -E -o file -pipe -pass-exit-codes -v --help -x language |
-ansi -fstd -fallow-single-precision -fcond-mismatch -fno-asm -fno-builtin -ffreestanding -fhosted -fsigned-bitfields -funsigned-bitfields -fsigned-char -funsigned-char -fwritable-strings -traditional -traditional-cpp -trigraphs |
-fno-access-control -fcheck-new -fconserve-space -fdollars-in-identifiers -fno-elide-constructors -fexternal-templates -ffor-scope -fno-for-scope -fno-gnu-keywords -fguiding-decls -fhonor-std -fhuge-objects -fno-implicit-templates -finit-priority -fno-implement-inlines -fname-mangling-version-n -fno-default-inline -fno-operator-names -fno-optional-diags -fpermissive -frepo -fstrict-prototype -fsquangle -ftemplate-depth-n -fuse-cxa-atexit -fvtable-thunks -nostdinc++ -Wctor-dtor-privacy -Wno-deprecated -Weffc++ -Wno-non-template-friend -Wnon-virtual-dtor -Wold-style-cast -Woverloaded-virtual -Wno-pmf-conversions -Wreorder -Wsign-promo -Wsynth |
-fsyntax-only -pedantic -pedantic-errors -w -W -Wall -Waggregate-return -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment -Wconversion -Werror -Wformat -Wid-clash-len -Wimplicit -Wimplicit-int -Wimplicit-function-declaration -Wimport -Werror-implicit-function-declaration -Wfloat-equal -Winline -Wlarger-than-len -Wlong-long -Wmain -Wmissing-declarations -Wmissing-noreturn -Wparentheses -Wparentheses-else -Wpointer-arith -Wredundant-decls -Wreturn-type -Wlongjmp-clobbers -Wshadow -Wsign-compare -Wstrict-prototypes -Wswitch -Wtraditional -Wmultichar -Wno-import -Wpacked -Wpadded -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wundef -Wuninitialized -Wunknown-pragmas -Wunreachable-code -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-variable -Wunused-value -Wwrite-strings |
-Wbad-function-cast -Wmissing-prototypes -Wnested-externs -Wstrict-prototypes -Wtraditional |
-dletters -fdump-unnumbered -fdump-translation-unit-file -fpretend-float -fprofile-arcs -ftest-coverage -g -glevel -gcoff -gdwarf -gdwarf-1 -gdwarf-1+ -gdwarf-2 -ggdb -gstabs -gstabs+ -gxcoff -gxcoff+ -p -pg -print-file-name=library -print-libgcc-file-name -print-prog-name=program -print-search-dirs -save-temps -time |
-falign-functions=n -falign-labels=n -falign-loops=n -falign-jumps=n -fbranch-probabilities -fcaller-saves -fcse-follow-jumps -fcse-skip-blocks -flive-range -fdelayed-branch -fdelete-null-pointer-checks -fexpensive-optimizations -ffast-math -ffloat-store -fforce-addr -fforce-mem -fno-math-errno -fdata-sections -ffunction-sections -fgcse -finline-functions -finline-limit=n -fkeep-inline-functions -fmove-all-movables -fno-default-inline -fno-defer-pop -fno-function-cse -fno-inline -fno-peephole -fomit-frame-pointer -foptimize-register-moves -foptimize-sibling-calls -fregmove -frerun-cse-after-loop -frerun-loop-opt -freduce-all-givs -fschedule-insns -fschedule-insns2 -fssa -fstrength-reduce -fstrict-aliasing -fthread-jumps -funroll-all-loops -funroll-loops -O -O0 -O1 -O2 -O3 -Os |
-Aquestion(answer) -C -dD -dM -dN -Dmacro[=defn] -E -H -idirafter dir -include file -imacros file -iprefix file -iwithprefix dir -iwithprefixbefore dir -isystem dir -isystem-c++ dir -M -MD -MM -MMD -MG -nostdinc -P -trigraphs -undef -Umacro -Wp,option |
-Wa,option |
object-file-name -llibrary -nostartfiles -nodefaultlibs -nostdlib -s -static -shared -symbolic -Wl,option -Xlinker option -u symbol |
-Bprefix -Idir -I- -Ldir -specs=file |
-mcpu=cpu type -mips1 -mips2 -mips3 -mips4 -mips5 -mips32 -mips32r2 -mips64 -mips64r2 -mips16 -mips16e -msmartmips -mips3D -mcode-xonly -mno-data-in-code -muse-all-regs -mbranch-likely -mcheck-zero-division -mno-check-zero-division -mdiv-checks -mno-div-checks -mconst-mult -mno-const-mult -mfp32 -mfp64 -mgp32 -mgp64 -msplit-addresses -mrnames -mgpopt -mstats -mmemcpy -msoft-float -mhard-float -msingle-float -mslow-mul -mno-mul -mmad -mno-mad -membedded-data -mno-embedded-data -mgpconst -mno-gpconst -muninit-const-in-rodata -mno-uninit-const-in-rodata -mlong-calls -mcommon-prolog -mentry -EL -EB -G num -nocpp -mabi=32 -mabi=n32 -mabi=64 -mabi=eabi -mabi=meabi -mabicalls -mno-abicalls -mint64 -mlong64 -mgas -mmips-as -mhalf-pic -mno-half-pic -membedded-pic -mno-embedded-pic -mmips-tfile -mno-mips-tfile |
-fcall-saved-reg -fcall-used-reg -fexceptions -funwind-tables -ffixed-reg -finhibit-size-directive -fcheck-memory-usage -fprefix-function-name -fno-common -fcommon -fno-ident -fno-gnu-linker -fpcc-struct-return -fpic -fPIC -freg-struct-return -fshared-data -fshort-enums -fshort-double -fvolatile -fvolatile-global -fvolatile-static -funaligned-pointers -funaligned-struct-hack -foptimize-comparisons -fverbose-asm -fpack-struct -fstack-check -fstack-limit-register=reg -fstack-limit-symbol=sym -fargument-alias -fargument-noalias -fargument-noalias-global -fleading-underscore |
2.2 Options Controlling the Kind of Output | Controlling the kind of output: an executable, object files, assembler files, or preprocessed source. | |
2.4 Options Controlling C Dialect | Controlling the variant of C language compiled. | |
2.5 Options Controlling C++ Dialect | Variations on C++. | |
2.6 Options to Request or Suppress Warnings | How picky should the compiler be? | |
2.7 Options for Debugging Your Program or GCC | Symbol tables, measurements, and debugging dumps. | |
2.8 Options That Control Optimization | How much optimization? | |
2.9 Options Controlling the Preprocessor | Controlling header files and macro definitions. Also, getting dependency information for Make. | |
2.10 Passing Options to the Assembler | Passing options to the assembler. | |
2.11 Options for Linking | Specifying libraries and so on. | |
2.12 Options for Directory Search | Where to find header files and libraries. Where to find the compiler executable files. | |
2.13 Specifying subprocesses and the switches to pass to them | How to pass switches to sub-processes. |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Compilation can involve up to four stages: preprocessing, compilation proper, assembly and linking, always in that order. The first three stages apply to an individual source file, and end by producing an object file; linking combines all the object files (those newly compiled, and those specified as input) into an executable file.
For any given input file, the file name suffix determines what kind of compilation is done:
file.c
file.i
file.ii
file.m
file.h
file.cc
file.cxx
file.cpp
file.C
file.s
file.S
file.sx
other
You can specify the input language explicitly with the `-x' option:
-x language
c objective-c c++ c-header cpp-output c++-cpp-output assembler assembler-with-cpp |
-x none
-pass-exit-codes
gcc
program will exit with the code of 1 if any
phase of the compiler returns a non-success return code. If you specify
`-pass-exit-codes', the gcc
program will instead return with
numerically highest error produced by any phase that returned an error
indication.
If you only want some of the stages of compilation, you can use
`-x' (or filename suffixes) to tell gcc
where to start, and
one of the options `-c', `-S', or `-E' to say where
gcc
is to stop. Note that some combinations (for example,
`-x cpp-output -E' instruct gcc
to do nothing at all.
-c
By default, the object file name for a source file is made by replacing the suffix `.c', `.i', `.s', etc., with `.o'.
Unrecognized input files, not requiring compilation or assembly, are ignored.
-S
By default, the assembler file name for a source file is made by replacing the suffix `.c', `.i', etc., with `.s'.
Input files that don't require compilation are ignored.
-E
Input files which don't require preprocessing are ignored.
-o file
Since only one output file can be specified, it does not make sense to use `-o' when compiling more than one input file, unless you are producing an executable file as output.
If `-o' is not specified, the default is to put an executable file in `a.out', the object file for `source.suffix' in `source.o', its assembler file in `source.s', and all preprocessed C source on standard output.
-v
-pipe
--print-multi-directory
--print-search-dirs
--print-file-name=file
--print-prog-name=program
--help
gcc
. If the -v
option is also specified
then --help
will also be passed on to the various processes
invoked by gcc
, so that they can display the command line options
they accept. If the -W
option is also specified then command
line options which have no documentation associated with them will also
be displayed.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
C++ source files conventionally use one of the suffixes `.C',
`.cc', `.cpp', `.c++', `.cp', or `.cxx';
preprocessed C++ files use the suffix `.ii'. GCC recognizes
files with these names and compiles them as C++ programs even if you
call the compiler the same way as for compiling C programs (usually with
the name gcc
).
However, C++ programs often require class libraries as well as a
compiler that understands the C++ language--and under some
circumstances, you might want to compile programs from standard input,
or otherwise without a suffix that flags them as C++ programs.
g++
is a program that calls GCC with the default language
set to C++, and automatically specifies linking against the C++
library. On many systems, the script g++
is also
installed with the name c++
.
When you compile C++ programs, you may specify many of the same command-line options that you use for compiling programs in any language; or command-line options meaningful for C and related languages; or options that are meaningful only for C++ programs. See section Options Controlling C Dialect, for explanations of options for languages related to C. See section Options Controlling C++ Dialect, for explanations of options that are meaningful only for C++ programs.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The following options control the dialect of C (or languages derived from C, such as C++ and Objective C) that the compiler accepts:
-ansi
This turns off certain features of GCC that are incompatible with ANSI
C (when compiling C code), or of standard C++ (when compiling C++ code),
such as the asm
and typeof
keywords, and
predefined macros such as unix
and vax
that identify the
type of system you are using. It also enables the undesirable and
rarely used ANSI trigraph feature. For the C compiler,
it disables recognition of C++ style `//' comments as well as
the inline
keyword.
The alternate keywords __asm__
, __extension__
,
__inline__
and __typeof__
continue to work despite
`-ansi'. You would not want to use them in an ANSI C program, of
course, but it is useful to put them in header files that might be included
in compilations done with `-ansi'. Alternate predefined macros
such as __unix__
and __vax__
are also available, with or
without `-ansi'.
The `-ansi' option does not cause non-ANSI programs to be rejected gratuitously. For that, `-pedantic' is required in addition to `-ansi'. See section 2.6 Options to Request or Suppress Warnings.
The macro __STRICT_ANSI__
is predefined when the `-ansi'
option is used. Some header files may notice this macro and refrain
from declaring certain functions or defining certain macros that the
ANSI standard doesn't call for; this is to avoid interfering with any
programs that might use these names for other things.
The functions alloca
, abort
, exit
, and
_exit
are not builtin functions when `-ansi' is used.
-fstd=
Even when this option is not specified, you can still use some of the
features of newer standards in so far as they do not conflict with
previous C standards. For example, you may use __restrict__
even
when -fstd=c9x is not specified.
-fno-asm
asm
, inline
or typeof
as a
keyword, so that code can use these words as identifiers. You can use
the keywords __asm__
, __inline__
and __typeof__
instead. `-ansi' implies `-fno-asm'.
In C++, this switch only affects the typeof
keyword, since
asm
and inline
are standard keywords. You may want to
use the `-fno-gnu-keywords' flag instead, which has the same effect.
-fno-builtin
abort
,
abs
, alloca
, cos
, cosf
, cosl
,
exit
, _exit
, fabs
, fabsf
, fabsl
,
ffs
, labs
, memcmp
, memcpy
, memset
,
sin
, sinf
, sinl
, sqrt
, sqrtf
,
sqrtl
, strcmp
, strcpy
, and strlen
.
GCC normally generates special code to handle certain builtin functions
more efficiently; for instance, calls to alloca
may become single
instructions that adjust the stack directly, and calls to memcpy
may become inline copy loops. The resulting code is often both smaller
and faster, but since the function calls no longer appear as such, you
cannot set a breakpoint on those calls, nor can you change the behavior
of the functions by linking with a different library.
The `-ansi' option prevents alloca
, ffs
and _exit
from being builtin functions, since these functions do not have an ANSI
standard meaning.
-fhosted
Assert that compilation takes place in a hosted environment. This implies
`-fbuiltin'. A hosted environment is one in which the
entire standard library is available, and in which main
has a return
type of int
. Examples are nearly everything except a kernel.
This is equivalent to `-fno-freestanding'.
-ffreestanding
Assert that compilation takes place in a freestanding environment. This
implies `-fno-builtin'. A freestanding environment
is one in which the standard library may not exist, and program startup may
not necessarily be at main
. The most obvious example is an OS kernel.
This is equivalent to `-fno-hosted'.
-trigraphs
-traditional
extern
declarations take effect globally even if they
are written inside of a function definition. This includes implicit
declarations of functions.
typeof
, inline
, signed
, const
and volatile
are not recognized. (You can still use the
alternative keywords such as __typeof__
, __inline__
, and
so on.)
unsigned short
and unsigned char
promote
to unsigned int
.
register
are preserved by
longjmp
. Ordinarily, GNU C follows ANSI C: automatic variables
not declared volatile
may be clobbered.
You may wish to use `-fno-builtin' as well as `-traditional' if your program uses names that are normally GNU C builtin functions for other purposes of its own.
You cannot use `-traditional' if you include any header files that rely on ANSI C features. Some vendors are starting to ship systems with ANSI C header files and you cannot use `-traditional' on such systems to compile files that include any system headers.
The `-traditional' option also enables `-traditional-cpp', which is described next.
-traditional-cpp
__STDC__
is not defined when you use
`-traditional', but __GNUC__
is (since the GNU extensions
which __GNUC__
indicates are not affected by
`-traditional'). If you need to write header files that work
differently depending on whether `-traditional' is in use, by
testing both of these predefined macros you can distinguish four
situations: GNU C, traditional GNU C, other ANSI C compilers, and other
old C compilers. The predefined macro __STDC_VERSION__
is also
not defined when you use `-traditional'. See section `Standard Predefined Macros' in The C Preprocessor,
for more discussion of these and other predefined macros.
-fcond-mismatch
-funsigned-char
char
be unsigned, like unsigned char
.
Each kind of machine has a default for what char
should
be. It is either like unsigned char
by default or like
signed char
by default.
Ideally, a portable program should always use signed char
or
unsigned char
when it depends on the signedness of an object.
But many programs have been written to use plain char
and
expect it to be signed, or expect it to be unsigned, depending on the
machines they were written for. This option, and its inverse, let you
make such a program work with the opposite default.
The type char
is always a distinct type from each of
signed char
or unsigned char
, even though its behavior
is always just like one of those two.
-fsigned-char
char
be signed, like signed char
.
Note that this is equivalent to `-fno-unsigned-char', which is the negative form of `-funsigned-char'. Likewise, the option `-fno-signed-char' is equivalent to `-funsigned-char'.
You may wish to use `-fno-builtin' as well as `-traditional' if your program uses names that are normally GNU C builtin functions for other purposes of its own.
You cannot use `-traditional' if you include any header files that rely on ANSI C features. Some vendors are starting to ship systems with ANSI C header files and you cannot use `-traditional' on such systems to compile files that include any system headers.
-fsigned-bitfields
-funsigned-bitfields
-fno-signed-bitfields
-fno-unsigned-bitfields
signed
or unsigned
. By
default, such a bitfield is signed, because this is consistent: the
basic integer types such as int
are signed types.
However, when `-traditional' is used, bitfields are all unsigned no matter what.
-fwritable-strings
Writing into string constants is a very bad idea; "constants" should be constant.
-fallow-single-precision
Traditional K&R C promotes all floating point operations to double precision, regardless of the sizes of the operands. On the architecture for which you are compiling, single precision may be faster than double precision. If you must use `-traditional', but want to use single precision operations when the operands are single precision, use this option. This option has no effect when compiling with ANSI or GNU C conventions (the default).
-fshort-wchar
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This section describes the command-line options that are only meaningful
for C++ programs; but you can also use most of the GNU compiler options
regardless of what language your program is in. For example, you
might compile a file firstClass.C
like this:
g++ -g -frepo -O -c firstClass.C |
In this example, only `-frepo' is an option meant only for C++ programs; you can use the other options with any language supported by GCC.
Here is a list of options that are only for compiling C++ programs:
-fno-access-control
-fcheck-new
operator new
is non-null
before attempting to modify the storage allocated. The current Working
Paper requires that operator new
never return a null pointer, so
this check is normally unnecessary.
An alternative to using this option is to specify that your
operator new
does not throw any exceptions; if you declare it
`throw()', g++ will check the return value. See also `new
(nothrow)'.
-fconserve-space
main()
has
completed, you may have an object that is being destroyed twice because
two definitions were merged.
This option is no longer useful on most targets, now that support has been added for putting variables into BSS without making them common.
-fdollars-in-identifiers
-fembedded-cxx
template
, typename
, catch
,
throw
, try
, using
, namespace
, dynamic_cast
,
static_cast
, reinterpret_cast
, const_cast
, and
typeid
.
To make the warnings for these things be given as errors, add the
-pedantic-errors
flag.
-fno-elide-constructors
-fno-enforce-eh-specs
-fexternal-templates
This option is deprecated.
-falt-external-templates
This option is deprecated.
-ffor-scope
-fno-for-scope
The default if neither flag is given to follow the standard, but to allow and give a warning for old-style code that would otherwise be invalid, or have different behavior.
-fno-gnu-keywords
typeof
as a keyword, so that code can use this
word as an identifier. You can use the keyword __typeof__
instead.
`-ansi' implies `-fno-gnu-keywords'.
-fguiding-decls
This option implies `-fname-mangling-version-0', and will not work with other name mangling versions. Like all options that change the ABI, all C++ code, including libgcc.a must be built with the same setting of this option.
-fno-implicit-templates
-fhonor-std
namespace std
as a namespace, instead of ignoring
it. For compatibility with earlier versions of g++, the compiler will,
by default, ignore namespace-declarations
,
using-declarations
, using-directives
, and
namespace-names
, if they involve std
.
-fhuge-objects
This flag is not useful when compiling with -fvtable-thunks.
Like all options that change the ABI, all C++ code, including libgcc must be built with the same setting of this option.
-fmessage-length=n
-fno-implicit-templates
-fno-implicit-inline-templates
-finit-priority
-fno-implement-inlines
-fms-extensions
-fname-mangling-version-n
template <class T, class U> void foo(T t); |
Like all options that change the ABI, all C++ code, including libgcc must be built with the same setting of this option.
-fno-operator-names
and
, bitand
,
bitor
, compl
, not
, or
and xor
as
synonyms as keywords.
-fno-optional-diags
-fpermissive
-frepo
-fno-rtti
-fstrict-prototype
foo
can take any combination of arguments, as
in C. `-pedantic' implies `-fstrict-prototype' unless
overridden with `-fno-strict-prototype'.
Specifying this option will also suppress implicit declarations of functions.
This flag no longer affects declarations with C++ linkage.
-fsquangle
-fno-squangle
Like all options that change the ABI, all C++ code, including libgcc.a must be built with the same setting of this option.
-ftemplate-depth-n
-fuse-cxa-atexit
__cxa_atexit
function rather than the atexit
function.
This option is required for fully standards-compliant handling of static
destructors, but will only work if your C library supports
__cxa_atexit
.
-fvtable-thunks
This option also enables a heuristic for controlling emission of vtables; if a class has any non-inline virtual functions, the vtable will be emitted in the translation unit containing the first one of those.
In the MIPS SDE compiler `thunks' are used by default. Like all options that change the ABI, all C++ code, including libgcc.a must be built with the same setting of this option.
-nostdinc++
In addition, these optimization, warning, and code generation options have meanings only for C++ programs:
-fno-default-inline
-Wctor-dtor-privacy (C++ only)
-Wnon-virtual-dtor (C++ only)
-Wreorder (C++ only)
struct A { int i; int j; A(): j (0), i (1) { } }; |
Here the compiler will warn that the member initializers for `i' and `j' will be rearranged to match the declaration order of the members.
The following `-W...' options are not affected by `-Wall'.
-Weffc++ (C++ only)
-Wno-deprecated (C++ only)
-Wno-non-template-friend (C++ only)
-Wold-style-cast (C++ only)
-Woverloaded-virtual (C++ only)
-Wno-pmf-conversions (C++ only)
-Wsign-promo (C++ only)
-Wsynth (C++ only)
struct A { operator int (); A& operator = (int); }; main () { A a,b; a = b; } |
In this example, g++ will synthesize a default `A& operator = (const A&);', while cfront will use the user-defined `operator ='.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Warnings are diagnostic messages that report constructions which are not inherently erroneous but which are risky or suggest there may have been an error.
You can request many specific warnings with options beginning `-W', for example `-Wimplicit' to request warnings on implicit declarations. Each of these specific warning options also has a negative form beginning `-Wno-' to turn off warnings; for example, `-Wno-implicit'. This manual lists only one of the two forms, whichever is not the default.
These options control the amount and kinds of warnings produced by GCC:
-fsyntax-only
-pedantic
Valid ANSI C and ISO C++ programs should compile properly with or without this option (though a rare few will require `-ansi'). However, without this option, certain GNU extensions and traditional C and C++ features are supported as well. With this option, they are rejected.
`-pedantic' does not cause warning messages for use of the
alternate keywords whose names begin and end with `__'. Pedantic
warnings are also disabled in the expression that follows
__extension__
. However, only system header files should use
these escape routes; application programs should avoid them.
See section 3.36 Alternate Keywords.
This option is not intended to be useful; it exists only to satisfy pedants who would otherwise claim that GCC fails to support the ANSI standard.
Some users try to use `-pedantic' to check programs for strict ANSI C conformance. They soon find that it does not do quite what they want: it finds some non-ANSI practices, but not all--only those for which ANSI C requires a diagnostic.
A feature to report any failure to conform to ANSI C might be useful in some instances, but would require considerable additional work and would be quite different from `-pedantic'. We don't have plans to support such a feature in the near future.
-pedantic-errors
-w
-Wno-import
-Wchar-subscripts
char
. This is a common cause
of error, as programmers often forget that this type is signed on some
machines.
-Wcomment
-Wformat
printf
and scanf
, etc., to make sure that
the arguments supplied have types appropriate to the format string
specified.
-Wimplicit-int
-Wimplicit-function-declaration
-Werror-implicit-function-declaration
-Wimplicit
-Wmain
-Wmultichar
-Wparentheses
This option includes `-Wparentheses-else' below.
-Wparentheses-else
if
statement an else
branch belongs. Here is an example of
such a case:
{ if (a) if (b) foo (); else bar (); } |
In C, every else
branch belongs to the innermost possible if
statement, which in this example is if (b)
. This is often not
what the programmer expected, as illustrated in the above example by
indentation the programmer chose. When there is the potential for this
confusion, GNU C will issue a warning when this flag is specified.
To eliminate the warning, add explicit braces around the innermost
if
statement so there is no way the else
could belong to
the enclosing if
. The resulting code would look like this:
{ if (a) { if (b) foo (); else bar (); } } |
-Wreturn-type
int
. Also warn about any return
statement with no
return-value in a function whose return-type is not void
.
-Wswitch
switch
statement has an index of enumeral type
and lacks a case
for one or more of the named codes of that
enumeration. (The presence of a default
label prevents this
warning.) case
labels outside the enumeration range also
provoke warnings when this option is used.
-Wtrigraphs
-Wunused-function
-Wunused-label
To suppress this warning use the `unused' attribute (see section 3.29 Specifying Attributes of Variables).
-Wunused-parameter
To suppress this warning use the `unused' attribute (see section 3.29 Specifying Attributes of Variables).
-Wunused-variable
To suppress this warning use the `unused' attribute (see section 3.29 Specifying Attributes of Variables).
-Wunused-value
To suppress this warning cast the expression to `void'.
-Wunused
In order to get a warning about an unused function parameter, you must either specify `-W -Wunused' or separatly specify `-Wunused-parameter'.
-Wuninitialized
setjmp
call.
These warnings are possible only in optimizing compilation, because they require data flow information that is computed only when optimizing. If you don't specify `-O', you simply won't get these warnings.
These warnings occur only for variables that are candidates for
register allocation. Therefore, they do not occur for a variable that
is declared volatile
, or whose address is taken, or whose size
is other than 1, 2, 4 or 8 bytes. Also, they do not occur for
structures, unions or arrays, even when they are in registers.
Note that there may be no warning about a variable that is used only to compute a value that itself is never used, because such computations may be deleted by data flow analysis before the warnings are printed.
These warnings are made optional because GCC is not smart enough to see all the reasons why the code might be correct despite appearing to have an error. Here is one example of how this can happen:
{ int x; switch (y) { case 1: x = 1; break; case 2: x = 4; break; case 3: x = 5; } foo (x); } |
If the value of y
is always 1, 2 or 3, then x
is
always initialized, but GCC doesn't know this. Here is
another common case:
{ int save_y; if (change_y) save_y = y, y = new_y; ... if (change_y) y = save_y; } |
This has no bug because save_y
is used only if it is set.
This option also includes `-Wlongjmp-clobbers' below.
-Wlongjmp-clobbers
longjmp
. These warnings as well are possible only in
optimizing compilation.
This option also warns when a nonvolatile automatic variable might be
changed by a call to longjmp
. These warnings as well are possible
only in optimizing compilation.
The compiler sees only the calls to setjmp
. It cannot know
where longjmp
will be called; in fact, a signal handler could
call it at any point in the code. As a result, you may get a warning
even when there is in fact no problem because longjmp
cannot
in fact be called at the place which would cause a problem.
Some spurious warnings can be avoided if you declare all the functions
you use that never return as noreturn
. See section 3.23 Declaring Attributes of Functions.
-Wreorder (C++ only)
-Wunknown-pragmas
-Wall
The following `-W...' options are not implied by `-Wall'. Some of them warn about constructions that users generally do not consider questionable, but which occasionally you might wish to check for; others warn about constructions that are necessary or hard to avoid in some cases, and there is no simple way to modify the code to suppress the warning.
-W
foo (a) { if (a > 0) return a; } |
static
are not the first things in
a declaration. According to the C Standard, this usage is obsolescent.
x.h
:
struct s { int f, g; }; struct t { struct s h; int i; }; struct t x = { 1, 2, 3 }; |
x.h
would be implicitly initialized to zero:
struct s { int f, g, h; }; struct s x = { 3, 4 }; |
-Wfloat-equal
The idea behind this is that sometimes it is convenient (for the programmer) to consider floating-point values as approximations to infinitely precise real numbers. If you are doing this, then you need to compute (by analysing the code, or in some other way) the maximum or likely maximum error that the computation introduces, and allow for it when performing comparisons (and when producing output, but that's a different problem). In particular, instead of testing for equality, you would check to see whether the two values have ranges that overlap; and this is done with the relational operators, so equality comparisons are probably mistaken.
-Wtraditional (C only)
switch
statement has an operand of type long
.
static
function declaration follows a static
one.
This construct is not accepted by some traditional C compilers.
-Wundef
-Wshadow
-Wid-clash-len
-Wlarger-than-len
-Wpointer-arith
void
. GNU C assigns these types a size of 1, for
convenience in calculations with void *
pointers and pointers
to functions.
-Wbad-function-cast (C only)
int malloc()
is cast to anything *
.
-Wcast-qual
const char *
is cast
to an ordinary char *
.
-Wcast-align
char *
is cast to
an int *
on machines where integers can only be accessed at
two- or four-byte boundaries.
-Wwrite-strings
const char[length]
so that
copying the address of one into a non-const
char *
pointer will get a warning. These warnings will help you find at
compile time code that can try to write into a string constant, but
only if you have been very careful about using const
in
declarations and prototypes. Otherwise, it will just be a nuisance;
this is why we did not make `-Wall' request these warnings.
-Wconversion
Also, warn if a negative integer constant expression is implicitly
converted to an unsigned type. For example, warn about the assignment
x = -1
if x
is unsigned. But do not warn about explicit
casts like (unsigned) -1
.
-Wsign-compare
-Waggregate-return
-Wstrict-prototypes (C only)
-Wmissing-prototypes (C only)
-Wmissing-declarations
-Wmissing-noreturn
noreturn
.
Note these are only possible candidates, not absolute ones. Care should
be taken to manually verify functions actually do not ever return before
adding the noreturn
attribute, otherwise subtle code generation
bugs could be introduced.
-Wpacked
f.x
in struct bar
will be misaligned even though struct bar
does not itself
have the packed attribute:
struct foo { int x; char a, b, c, d; } __attribute__((packed)); struct bar { char z; struct foo f; }; |
-Wpadded
-Wredundant-decls
-Wnested-externs (C only)
extern
declaration is encountered within a function.
-Wunreachable-code
This option is intended to warn when the compiler detects that at least a whole line of source code will never be executed, because some condition is never satisfied or because it is after a procedure that never returns.
It is possible for this option to produce a warning even though there are circumstances under which part of the affected line can be executed, so care should be taken when removing apparently-unreachable code.
For instance, when a function is inlined, a warning may mean that the line is unreachable in only one inlined copy of the function.
This option is not made part of `-Wall' because in a debugging version of a program there is often substantial code which checks correct functioning of the program and is, hopefully, unreachable because the program does work. Another common use of unreachable code is to provide behaviour which is selectable at compile-time.
-Winline
-Wlong-long
-Werror
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
GCC has various special options that are used for debugging either your program or GCC:
-g
On most systems that use stabs format, `-g' enables use of extra debugging information that only GDB can use; this extra information makes debugging work better in GDB but will probably make other debuggers crash or refuse to read the program. If you want to control for certain whether to generate the extra information, use `-gstabs+', `-gstabs', `-gdwarf-1+', or `-gdwarf-1' (see below).
Unlike most other C compilers, GCC allows you to use `-g' with `-O'. The shortcuts taken by optimized code may occasionally produce surprising results: some variables you declared may not exist at all; flow of control may briefly move where you did not expect it; some statements may not be executed because they compute constant results or their values were already at hand; some statements may execute in different places because they were moved out of loops.
Nevertheless it proves possible to debug optimized output. This makes it reasonable to use the optimizer for programs that might have bugs.
The following options are useful when GCC is generated with the capability for more than one debugging format.
-ggdb
-gstabs
-gstabs+
-gdwarf
-gdwarf+
-gdwarf-2
-glevel
-ggdblevel
-gstabslevel
-gdwarflevel
-gdwarf-2level
Level 1 produces minimal information, enough for making backtraces in parts of the program that you don't plan to debug. This includes descriptions of functions and external variables, but no information about local variables and no line numbers.
Level 3 includes extra information, such as all the macro definitions present in the program. Some debuggers support macro expansion when you use `-g3'.
-p
prof
. You must use this option when compiling
the source files you want data about, and you must also use it when
linking.
-pg
gprof
. You must use this option when compiling
the source files you want data about, and you must also use it when
linking.
-Q
-fprofile-arcs
Since not every arc in the program must be instrumented, programs
compiled with this option run faster than programs compiled with
`-a', which adds instrumentation code to every basic block in the
program. The tradeoff: since gcov
does not have
execution counts for all branches, it must start with the execution
counts for the instrumented branches, and then iterate over the program
flow graph until the entire graph has been solved. Hence, gcov
runs a little more slowly than a program which uses information from
`-a'.
`-fprofile-arcs' also makes it possible to estimate branch probabilities, and to calculate basic block execution counts. In general, basic block execution counts do not give enough information to estimate all branch probabilities. When the compiled program exits, it saves the arc execution counts to a file called `sourcename.da'. Use the compiler option `-fbranch-probabilities' (see section Options that Control Optimization) when recompiling, to optimize using estimated branch probabilities.
-ftest-coverage
gcov
code-coverage utility
(see section gcov
: a GCC Test Coverage Program).
The data file names begin with the name of your source file:
sourcename.bb
gcov
uses to
associate basic block execution counts with line numbers.
sourcename.bbg
gcov
to reconstruct the program flow graph, so that it can compute all basic
block and arc execution counts from the information in the
sourcename.da
file (this last file is the output from
`-fprofile-arcs').
-dletters
ADDRESSOF
codes, to `file.04.addressof'.
-fdump-unnumbered
-fdump-translation-unit-file (C++ only)
-fpretend-float
-save-temps
-time
# cpp 0.04 0.04 # cc1 0.12 0.01 # as 0.00 0.01 |
The first number on each line is the "user time," that is time spent executing the program itself. The second number is "system time," time spent executing operating system routines on behalf of the program. Both numbers are in seconds.
-print-file-name=library
-print-prog-name=program
-print-libgcc-file-name
This is useful when you use `-nostdlib' or `-nodefaultlibs' but you do want to link with `libgcc.a'. You can do
gcc -nostdlib files... `gcc -print-libgcc-file-name` |
-print-search-dirs
This is useful when gcc prints the error message
`installation problem, cannot exec cpp: No such file or directory'.
To resolve this you either need to put `cpp' and the other compiler
components where gcc expects to find them, or you can set the environment
variable GCC_EXEC_PREFIX
to the directory where you installed them.
Don't forget the trailing '/'.
See section 2.17 Environment Variables Affecting GCC.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These options control various sorts of optimizations:
-O
-O1
Without `-O', the compiler's goal is to reduce the cost of compilation and to make debugging produce the expected results. Statements are independent: if you stop the program with a breakpoint between statements, you can then assign a new value to any variable or change the program counter to any other statement in the function and get exactly the results you would expect from the source code.
Without `-O', the compiler only allocates variables declared
register
in registers. The resulting compiled code is a little
worse than produced by PCC without `-O'.
With `-O', the compiler tries to reduce code size and execution time.
When you specify `-O', the compiler turns on `-fthread-jumps'
and
`-fdefer-pop' on all machines. The compiler turns on
`-fdelayed-branch' on machines that have delay slots, and
`-fomit-frame-pointer' on machines that can support debugging even
without a frame pointer. On some machines the compiler also turns
on other flags.
-O2
`-O2' turns on all optional optimizations except for loop unrolling and function inlining. It also turns on the `-fforce-mem' option on all machines and frame pointer elimination on machines where doing so does not interfere with debugging.
-O3
-O0
-Os
If you use multiple `-O' options, with or without level numbers, the last such option is the one that is effective.
Options of the form `-fflag' specify machine-independent flags. Most flags have both positive and negative forms; the negative form of `-ffoo' would be `-fno-foo'. In the table below, only one of the forms is listed--the one which is not the default. You can figure out the other form by either removing `no-' or adding it.
-ffloat-store
This option prevents undesirable excess precision on machines such as
the 68000 where the floating registers (of the 68881) keep more
precision than a double
is supposed to have. Similarly for the
x86 architecture. For most programs, the excess precision does only
good, but a few programs rely on the precise definition of IEEE floating
point. Use `-ffloat-store' for such programs, after modifying
them to store all pertinent intermediate computations into variables.
-fno-default-inline
-fno-defer-pop
-fforce-mem
-fforce-addr
-fomit-frame-pointer
On some machines, such as the Vax, this flag has no effect, because
the standard calling sequence automatically handles the frame pointer
and nothing is saved by pretending it doesn't exist. The
machine-description macro FRAME_POINTER_REQUIRED
controls
whether a target machine supports this flag. See section `Register Usage' in Using and Porting GCC.
-foptimize-sibling-calls
-fno-inline
inline
keyword. Normally this option
is used to keep the compiler from expanding any functions inline.
Note that if you are not optimizing, no functions can be expanded inline.
-finline-functions
If all calls to a given function are integrated, and the function is
declared static
, then the function is normally not output as
assembler code in its own right.
-finline-limit=n
Note: pseudo instruction represents, in this particular context, an abstract measurement of function's size. In no way, it represents a count of assembly instructions and as such its exact meaning might change from one release to an another.
-fkeep-inline-functions
static
, nevertheless output a separate run-time
callable version of the function. This switch does not affect
extern inline
functions.
-fkeep-static-consts
static const
when optimization isn't turned
on, even if the variables aren't referenced.
GCC enables this option by default. If you want to force the compiler to check if the variable was referenced, regardless of whether or not optimization is turned on, use the `-fno-keep-static-consts' option.
-fno-function-cse
This option results in less efficient code, but some strange hacks that alter the assembler output may be confused by the optimizations performed when this option is not used.
-ffast-math
sqrt
function are non-negative numbers and that no floating-point values
are NaNs.
Where the CPU provides fast but non-IEEE-compliant instructions (like MIPS IV's reciprocal and reciprocal square root) the compiler takes this flag as an OK to use them.
This option should never be turned on by any `-O' option since it can result in incorrect output for programs which depend on an exact implementation of IEEE or ANSI rules/specifications for math functions.
-fno-math-errno
The default is `-fmath-errno'. The `-ffast-math' option sets `-fno-math-errno'.
The following options control specific optimizations. The `-O2' option turns on all of these optimizations except `-funroll-loops' and `-funroll-all-loops'. On most machines, the `-O' option turns on the `-fthread-jumps' and `-fdelayed-branch' options, but specific machines may handle it differently.
You can use the following flags in the rare cases when "fine-tuning" of optimizations to be performed is desired.
-fstrength-reduce
-fthread-jumps
-fcse-follow-jumps
if
statement with an
else
clause, CSE will follow the jump when the condition
tested is false.
-fcse-skip-blocks
if
statement with no else clause,
`-fcse-skip-blocks' causes CSE to follow the jump around the
body of the if
.
-frerun-cse-after-loop
-frerun-loop-opt
-fgcse
-flive-range
-fdelete-null-pointer-checks
-fexpensive-optimizations
-foptimize-register-moves
-fregmove
Note -fregmove
and -foptimize-register-moves
are the same
optimization.
-fdelayed-branch
-fschedule-insns
-fschedule-insns2
-ffunction-sections
-fdata-sections
Use these options on systems where the linker can perform optimizations to improve locality of reference in the instruction space. HPPA processors running HP-UX and Sparc processors running Solaris 2 have linkers with such optimizations. Other systems using the ELF object format as well as AIX may have these optimizations in the future.
Only use these options when there are significant benefits from doing
so. When you specify these options, the assembler and linker will
create larger object and executable files and will also be slower.
You will not be able to use gprof
on all systems if you
specify this option and you may have problems with debugging if
you specify both this option and `-g'.
-fcaller-saves
This option is always enabled by default on certain machines, usually those which have no call-preserved registers to use instead.
For all machines, optimization level 2 and higher enables this flag by default.
-funroll-loops
-funroll-all-loops
-fmove-all-movables
-freduce-all-givs
Note: When compiling programs written in Fortran, `-fmove-all-movables' and `-freduce-all-givs' are enabled by default when you use the optimizer.
These options may generate better or worse code; results are highly dependent on the structure of loops within the source code.
These two options are intended to be removed someday, once they have helped determine the efficacy of various approaches to improving loop optimizations.
Please let us (support@mips.com and/or gcc@gcc.gnu.org
)
know how use of these options affects
the performance of your production code.
We're very interested in code that runs slower
when these options are enabled.
-fno-peephole
-fbranch-probabilities
gcc
), you can compile it a second time using
`-fbranch-probabilities', to improve optimizations based on
guessing the path a branch might take.
-fstrict-aliasing
unsigned int
can alias an int
, but not a
void*
or a double
. A character type may alias any other
type.
Pay special attention to code like this:
union a_union { int i; double d; }; int f() { a_union t; t.d = 3.0; return t.i; } |
int f() { a_union t; int* ip; t.d = 3.0; ip = &t.i; return *ip; } |
-falign-functions
-falign-functions=n
`-fno-align-functions' and `-falign-functions=1' are equivalent and mean that functions will not be aligned.
Some assemblers only support this flag when n is a power of two; in that case, it is rounded up.
If n is not specified, use a machine-dependent default.
-falign-labels
-falign-labels=n
If `-falign-loops' or `-falign-jumps' are applicable and are greater than this value, then their values are used instead.
If n is not specified, use a machine-dependent default which is very likely to be `1', meaning no alignment.
-falign-loops
-falign-loops=n
If n is not specified, use a machine-dependent default.
-falign-jumps
-falign-jumps=n
If n is not specified, use a machine-dependent default.
-fssa
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These options control the C preprocessor, which is run on each C source file before actual compilation.
If you use the `-E' option, nothing is done except preprocessing. Some of these options make sense only together with `-E' because they cause the preprocessor output to be unsuitable for actual compilation.
-include file
-imacros file
Any `-D' and `-U' options on the command line are always processed before `-imacros file', regardless of the order in which they are written. All the `-include' and `-imacros' options are processed in the order in which they are written.
-idirafter dir
-iprefix prefix
-iwithprefix dir
-iwithprefixbefore dir
-isystem dir
-isystem-c++ dir
-nostdinc
By using both `-nostdinc' and `-I-', you can limit the include-file search path to only those directories you specify explicitly.
-undef
-E
-C
-P
-M
make
describing the dependencies of each object file. For each source file,
the preprocessor outputs one make
-rule whose target is the object
file name for that source file and whose dependencies are all the
#include
header files it uses. This rule may be a single line or
may be continued with `\'-newline if it is long. The list of rules
is printed on standard output instead of the preprocessed C program.
`-M' implies `-E'.
Another way to specify output of a make
rule is by setting
the environment variable DEPENDENCIES_OUTPUT
(see section 2.17 Environment Variables Affecting GCC).
-MM
-MD
In Mach, you can use the utility md
to merge multiple dependency
files into a single dependency file suitable for using with the `make'
command.
-MMD
-MG
-H
-Aquestion(answer)
-Dmacro
-Dmacro=defn
-Umacro
-dM
-dD
-dN
-trigraphs
-Wp,option
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
You can pass options to the assembler.
-Wa,option
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These options come into play when the compiler links object files into an executable output file. They are meaningless if the compiler is not doing a link step.
object-file-name
-c
-S
-E
-llibrary
It makes a difference where in the command you write this option; the linker searches processes libraries and object files in the order they are specified. Thus, `foo.o -lz bar.o' searches library `z' after file `foo.o' but before `bar.o'. If `bar.o' refers to functions in `z', those functions may not be loaded.
The linker searches a standard list of directories for the library, which is actually a file named `liblibrary.a'. The linker then uses this file as if it had been specified precisely by name.
The directories searched include several standard system directories plus any that you specify with `-L'.
But since this is a cross-compiler for multiple targets, there are some flags to the compiler which produce incompatible code; the actual library files you used depend on those flags. The "multi-lib" feature puts a different library root directory in the search path to match what your flags have asked for.
The flags which affect the choice of library are:
-EB, -EL
-mips1, -mips2
-mips3, -mips4
-mips32
-mips32r2
-mips64, -mips64r2
-mips16, -mips16e
-mgp32
-mfp64
-mno-float
-msoft-float
-msingle-float
You might reasonably expect there to be different libraries for `-G0' and `-G8' but there aren't; `-G0' might in theory be less efficient, but the effect is very small and its completely compatible, so all the libraries are built that way.
Normally the files found this way are library files--archive files whose members are object files. The linker handles an archive file by scanning through it for members which define symbols that have so far been referenced but not defined. But if the file that is found is an ordinary object file, it is linked in the usual fashion. The only difference between using an `-l' option and specifying a file name is that `-l' surrounds library with `lib' and `.a' and searches several directories.
-lobjc
-nostartfiles
-nostdlib
or -nodefaultlibs
is used.
-nodefaultlibs
-nostartfiles
is used. The compiler may generate calls to memcmp, memset, and memcpy
for System V (and ANSI C) environments or to bcopy and bzero for
BSD environments. These entries are usually resolved by entries in
libc. These entry points should be supplied through some other
mechanism when this option is specified.
-nostdlib
One of the standard libraries bypassed by `-nostdlib' and `-nodefaultlibs' is `libgcc.a', a library of internal subroutines that GCC uses to overcome shortcomings of particular machines, or special needs for some languages. (See section `Interfacing to GCC Output' in Porting GCC, for more discussion of `libgcc.a'.) In most cases, you need `libgcc.a' even when you want to avoid other standard libraries. In other words, when you specify `-nostdlib' or `-nodefaultlibs' you should usually specify `-lgcc' as well. This ensures that you have no unresolved references to internal GCC library subroutines.
-s
-static
-shared
-symbolic
-Xlinker option
If you want to pass an option that takes an argument, you must use `-Xlinker' twice, once for the option and once for the argument. For example, to pass `-assert definitions', you must write `-Xlinker -assert -Xlinker definitions'. It does not work to write `-Xlinker "-assert definitions"', because this passes the entire string as a single argument, which is not what the linker expects.
-Wl,option
-u symbol
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These options specify directories to search for header files, for libraries and for parts of the compiler:
-Idir
-I-
If additional directories are specified with `-I' options after the `-I-', these directories are searched for all `#include' directives. (Ordinarily all `-I' directories are used this way.)
In addition, the `-I-' option inhibits the use of the current directory (where the current input file came from) as the first search directory for `#include "file"'. There is no way to override this effect of `-I-'. With `-I.' you can specify searching the directory which was current when the compiler was invoked. That is not exactly the same as what the preprocessor does by default, but it is often satisfactory.
`-I-' does not inhibit the use of the standard system directories for header files. Thus, `-I-' and `-nostdinc' are independent.
-Ldir
-Bprefix
The compiler driver program runs one or more of the subprograms `cpp', `cc1', `as' and `ld'. It tries prefix as a prefix for each program it tries to run.
For each subprogram to be run, the compiler driver first tries the
`-B' prefix, if any. If that name is not found, or if `-B'
was not specified, the driver tries two standard prefixes, which are
`/usr/lib/gcc/' and
`/usr/local/lib/gcc-lib/'. If neither of
those results in a file name that is found, the unmodified program
name is searched for using the directories specified in your
`PATH' environment variable.
`-B' prefixes that effectively specify directory names also apply to libraries in the linker, because the compiler translates these options into `-L' options for the linker. They also apply to includes files in the preprocessor, because the compiler translates these options into `-isystem' options for the preprocessor. In this case, the compiler appends `include' to the prefix.
The run-time support file `libgcc.a' can also be searched for using the `-B' prefix, if needed. If it is not found there, the two standard prefixes above are tried, and that is all. The file is left out of the link if it is not found by those means.
Another way to specify a prefix much like the `-B' prefix is to use
the environment variable GCC_EXEC_PREFIX
. See section 2.17 Environment Variables Affecting GCC.
-specs=file
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
GCC
is a driver program. It performs its job by invoking a
sequence of other programs to do the work of compiling, assembling and
linking. GCC interprets its command-line parameters and uses these to
deduce which programs it should invoke, and which command-line options
it ought to place on their command lines. This behaviour is controlled
by spec strings. In most cases there is one spec string for each
program that GCC can invoke, but a few programs have multiple spec
strings to control their behaviour. The spec strings built into GCC can
be overridden by using the `-specs=' command-line switch to specify
a spec file.
Spec files are plaintext files that are used to construct spec strings. They consist of a sequence of directives separated by blank lines. The type of directive is determined by the first non-whitespace character on the line and it can be one of the following:
%command
%include <file>
%include_noerr <file>
%rename old_name new_name
*[spec_name]:
[suffix]:
.ZZ: z-compile -input %i |
This says that any input file whose name ends in `.ZZ' should be passed to the program `z-compile', which should be invoked with the command-line switch `-input' and with the result of performing the `%i' substitution. (See below.)
As an alternative to providing a spec string, the text that follows a suffix directive can be one of the following:
@language
-x
command-line switch to GCC to specify a
language explicitly. For example:
.ZZ: @c++ |
Says that .ZZ files are, in fact, C++ source files.
#name
name compiler not installed on this system. |
GCC already has an extensive list of suffixes built into it. This directive will add an entry to the end of the list of suffixes, but since the list is searched from the end backwards, it is effectively possible to override earlier entries using this technique.
GCC has the following spec strings built into it. Spec files can override these strings or create their own. Note that individual targets can also add their own spec strings to this list.
asm Options to pass to the assembler
asm_final Options to pass to the assembler post-processor
cpp Options to pass to the C preprocessor
cc1 Options to pass to the C compiler
cc1plus Options to pass to the C++ compiler
endfile Object files to include at the end of the link
link Options to pass to the linker
lib Libraries to include on the command line to the linker
libgcc Decides which GCC support library to pass to the linker
linker Sets the name of the linker
predefines Defines to be passed to the C preprocessor
signed_char Defines to pass to CPP to say whether |
Here is a small example of a spec file:
%rename lib old_lib *lib: --start-group -lgcc -lc -leval1 --end-group %(old_lib) |
This example renames the spec called `lib' to `old_lib' and then overrides the previous definition of `lib' with a new one. The new definition adds in some extra command-line options before including the text of the old definition.
Spec strings are a list of command-line options to be passed to their corresponding program. In addition, the spec strings can contain `%'-prefixed sequences to substitute variable text or to conditionally insert text into the command line. Using these constructs it is possible to generate quite complex command lines.
Here is a table of all defined `%'-sequences for spec strings. Note that spaces are not generated automatically around the results of expanding these sequences. Therefore you can concatenate them together or combine them with constant text in a single argument.
%%
%i
%b
%d
%gsuffix
%usuffix
%Usuffix
%w
%o
%O
%p
cpp
.
%P
%I
%s
%estr
%|
%(name)
%[name]
%x{option}
%X
%Y
%Z
%v1
%v2
%a
asm
spec. This is used to compute the
switches to be passed to the assembler.
%A
asm_final
spec. This is a spec string for
passing switches to an assembler post-processor, if such a program is
needed.
%l
link
spec. This is the spec for computing the
command line passed to the linker. Typically it will make use of the
`%L %G %S %D and %E' sequences.
%D
%L
lib
spec. This is a spec string for deciding which
libraries should be included on the command line to the linker.
%G
libgcc
spec. This is a spec string for deciding
which GCC support library should be included on the command line to the linker.
%S
startfile
spec. This is a spec for deciding which
object files should be the first ones passed to the linker. Typically
this might be a file named `crt0.o'.
%E
endfile
spec. This is a spec string that specifies
the last object files that will be passed to the linker.
%C
cpp
spec. This is used to construct the arguments
to be passed to the C preprocessor.
%c
signed_char
spec. This is intended to be used
to tell cpp whether a char is signed. It typically has the definition:
%{funsigned-char:-D__CHAR_UNSIGNED__} |
%1
cc1
spec. This is used to construct the options to be
passed to the actual C compiler (`cc1').
%2
cc1plus
spec. This is used to construct the options to be
passed to the actual C++ compiler (`cc1plus').
%*
%{S
}
-S
switch, if that switch was given to GCC.
If that switch was not specified, this substitutes nothing. Note that
the leading dash is omitted when specifying this option, and it is
automatically inserted if the substitution is performed. Thus the spec
string `%{foo}' would match the command-line option `-foo'
and would output the command line option `-foo'.
%W{S
}
S
} but mark last argument supplied within as a file to be
deleted on failure.
%{S
*}
-S
, but which also take an argument. This is used for
switches like `-o, -D, -I', etc. GCC considers `-o foo' as being
one switch whose names starts with `o'. %{o*} would substitute this
text, including the space. Thus two arguments would be generated.
%{^S
*}
S
*}, but don't put a blank between a switch and its
argument. Thus %{^o*} would only generate one argument, not two.
%{<S
}
S
from the command line. Note - this
command is position dependent. `%' commands in the spec string
before this option will see S
, `%' commands in the spec
string after this option will not.
%{S
*:X
}
X
if one or more switches whose names start with
-S
are specified to GCC. Note that the tail part of the
-S
option (i.e. the part matched by the `*') will be substituted
for each occurrence of `%*' within X
.
%{S
:X
}
X
, but only if the `-S' switch was given to GCC.
%{!S
:X
}
X
, but only if the `-S' switch was not given to GCC.
%{|S
:X
}
S
:X
}, but if no S
switch, substitute `-'.
%{|!S
:X
}
S
:X
}, but if there is an S
switch, substitute `-'.
%{.S
:X
}
X
, but only if processing a file with suffix S
.
%{!.S
:X
}
X
, but only if not processing a file with suffix S
.
%{S
|P
:X
}
X
if either -S
or -P
was given to GCC. This may be
combined with `!' and `.' sequences as well, although they
have a stronger binding than the `|'. For example a spec string
like this:
%{.c:-foo} %{!.c:-bar} %{.c|d:-baz} %{!.c|d:-boggle} |
will output the following command-line options from the following input command-line options:
fred.c -foo -baz jim.d -bar -boggle -d fred.c -foo -baz -boggle -d jim.d -bar -baz -boggle |
The conditional text X
in a %{S
:X
} or
%{!S
:X
} construct may contain other nested `%' constructs
or spaces, or even newlines. They are processed as usual, as described
above.
The `-O, -f, -m, and -W' switches are handled specifically in these
constructs. If another value of `-O' or the negated form of a `-f, -m, or
-W' switch is found later in the command line, the earlier switch
value is ignored, except with {S
*} where S
is just one
letter, which passes all matching options.
The character `|' at the beginning of the predicate text is used to indicate that a command should be piped to the following command, but only if `-pipe' is specified.
It is built into GCC which switches take arguments and which do not. (You might think it would be useful to generalize this to allow each compiler's spec to say which switches take arguments. But this cannot be done in a consistent fashion. GCC cannot even decide which input files have been specified without knowing which switches take arguments, and it must know which input files to compile in order to tell which compilers to run).
GCC also knows implicitly that arguments starting in `-l' are to be treated as compiler output files, and passed to the linker in their proper position among the other output files.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Some GNU C installations allow you to use the same command name to compile for many different targets -- one of them perhaps native applications on your workstation. To manage support, MIPS SDE does not provide this level of option; if you have a different GNU compiler, it will be called `gcc' not `sde-gcc'. MIPS SDE does allow you to select from a large choice of MIPS cross-compilation targets; but that's described in the next section, Different CPUs and Configurations.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The compiler provided with MIPS SDE can generate code for a wide range of MIPS CPUs. Many of these CPU types have a special option, starting with `-m', which configures the compilation process towards that CPU's particular features--for example, R4640 vs R3000, floating-point coprocessor or none. A single installed version of the compiler can compile for any model or configuration, according to the options specified.
These `-m' options are defined for the MIPS family of computers:
-mcpu=cpu_type
Legitimate values for cpu_type are:
r1900, pr1900
r2k, r2000
r3k, r3000
r3900, pr3900, tx3900
rc32364, rc323xx
r4k, r4000, r4400
4kc, 4km, 4kec, 4kem
4kp, 4kep
4ksc, 4ksd
m4k
5kc, 5kf
24kc, 24kf
20kc
25kf
cw400x, cw4001, cw4002, cw4003
cw401x, cw4010, cw4011
atm2, atmizer2, apu
tr4101, ev4101
r4200, vr4200
r4100, vr4100
r4111, vr4111
r4300, vr4300
r4320, vr4320
r4600, r4700
r4640, r4650
r5k, r5000
rm52xx, rm5230, rm5260, rm5270
r54xx, r5400, r5432, r5464
vr54xx, vr5400, vr5432, vr5464
rc64574, rc64575, rc6457x
rm7k, rm7000
r6k, r6000
r10k, r10000
-mips1, -mips2, -mips3, -mips4
Each instruction set variant has a different default cpu_type; they are `r3000', `r6000', `r4000' and `r5000' respectively.
Although the `-mips2' default CPU is long obsolete, it's still a useful option to build code for a MIPS III CPU when you don't need any 64-bit specific instructions -- roughly equivalent to `-mips3 -mgp32 -mfp32', but your exception handlers don't have to save and restore the full 64-bit register set.
-mips5
-mips32
-mips64
-mips32r2, -mips64r2
-mips16
All functions in a C or C++ module built with `-mips16' are compiled using the narrower instructions, unless modified by the `nomips16' function attribute (see section 3.23 Declaring Attributes of Functions). MIPS16 functions may be freely interlinked with true MIPS functions. It is difficult and usually pointless to try to write assembler code for MIPS16; but inside an assembler module you can mix MIPS16 and conventional code using `.set mips16' and `.set nomips16' directives.
MIPS16 CPUs can be either 32-bit or 64-bit implementations. To generate 64-bit MIPS16 code, you should specify a 64-bit base ISA, e.g `-mips3 -mips16'.
-mips16e
Strictly the `-mips16e' option is not required--using the `-mips16' option will generate MIPS16e code if applied as a modifier to `-mips32' or `-mips64'. The only difference is that a `-mips16e' option used on its own will generate MIPS32 code in functions marked with the `nomips16' attribute, whereas `-mips16' would generate MIPS I code.
-msmartmips
asm
expressions.
-mips3D
asm
expressions.
-mcode-xonly
lwpc
instruction, which
is still used to load 32-bit immediates from the text section, following
the current function--it is handled specially by the CPU, which treats
the pc-relative data load as an instruction fetch.
-mno-data-in-code
const
attribute)
in the `text' section, immediately following the referencing
function, where they can be accessed using short PC-relative addresses.
Some MIPS Technologies cores support independent instruction and data memories (SPRAM), which can't read data from the I-memory without special hardware support. Use the `-mno-data-in-code' option when compiling MIPS16 code for a CPU like that. It will produce significantly larger code; so don't use it unless you really need it. When this option is used, it switches off the `-G 0' override which is normally used for MIPS16 code, so that it can place the implicit constants in the small data section and access them via the $gp register. If you specify the `-G 0' option explicitly, then the generated code will get even larger.
-muse-all-regs
-mbranch-likely
-mfp32
-mfp64
-mgp32
-mgp64
-mcheck-zero-division
-mno-check-zero-division
-mdiv-checks
-mno-div-checks
For MIPS CPUs the compiler generates code that explicitly checks for zero-valued divisors and traps when one is detected. Use of `-mno-check-zero-division' suppresses such checking.
The `-mdiv-checks' and `-mno-div-checks' flags are simply aliases for (respectively) the `-mcheck-zero-division' and `-mno-check-zero-division' flags, for compatibility with previous versions of MIPS SDE.
-msplit-addresses
-mno-split-addresses
-mrnames
-mno-rnames
-mgpopt
-mno-gpopt
-mstats
-mno-stats
-mmemcpy
-mno-memcpy
-msoft-float
-mhard-float
-mno-float
The `-mno-float' switch implies `-msoft-float' but goes further, by picking optional library variants at link time which don't provide any support for floating point data, and are therefore significantly smaller.
-mslow-mul
-mno-mul
-mmad
mad
and mul
instructions. Normally the
compiler decides whether it can use multiply-add and other extended
multiplier features automatically, using the selected CPU type and ISA.
-mconst-mult
-mno-const-mult
-membedded-data
-mno-embedded-data
-mgpconst
-mno-gpconst
Note that `-membedded-data' is the default setting for MIPS SDE. Alternatively select `-mno-embedded-data' if you want small constants to be placed in the small data section, instead of the read-only data section, for increased speed.
The `-mno-gpconst' and `-mgpconst' flags are just aliases to
the flags
`-membedded-data' and `-mno-embedded-data'
respectively, for compatibility with older versions of MIPS SDE.
-muninit-const-in-rodata
-mno-uninit-const-in-rodata
-mlong-calls
-mno-long-calls
jalr
instruction, which requires loading a
function's address into a register before the call. You may need to use
this switch if you link a program linked so that a calling function and
its matching callee are in separate 256Mbyte segments of memory. But
this is would be a bit drastic because it makes all calls much longer
and slower. You could use the `longcall' attribute
(see section 3.23 Declaring Attributes of Functions) to mark particular functions known to
require a long call.
-msingle-float
-mdouble-float
-mcommon-prolog
-mentry
-EL
-EB
-G num
By default, num is 8, but if your memory map or run-time system will not permit this technique then use `-G 0' to disable the optimisation. You can also increase the value to place more variables into the "fast" sections, but take care not to overflow the 64KB maximum size of the small data region.
The `-G num' switch is also passed to the assembler and linker. All modules must be compiled with the same `-G num' value.
Because GNU C is a mighty undertaking there are options supported by the compiler, but not supported by the rest of the MIPS SDE toolkit. For completeness they are listed here:
-mabi=32
-mabi=o64
-mabi=n32
-mabi=64
-mabi=eabi
-mabi=meabi
Note that `-mabi=o64' is a non-standard, undocumented ABI used by some other GNU toolchains for 64-bit code--essentially it's what you get if you stretch `-mabi=32' so that all argument registers and stack parameters are 64-bits wide. We only provide `o64' mode for compatibility with customers with code based that assume that calling convention, but it won't work with the MIPS SDE libraries, and is deprecated.
-mint64
-mlong64
-mlong32
If none of `-mlong32', `-mlong64', or `-mint64' are set, then the size of ints, longs, and pointers depends on the ABI and ISA chosen. For `-mabi=32', and `-mabi=n32', ints and longs are 32 bits wide. For `-mabi=64', ints are 32 bits, and longs are 64 bits wide. For `-mabi=eabi' and `-mabi=meabi' ints are always 32 bits, but the size of longs tracks the register size of the selected ISA. The width of pointers is always the same as the width of longs.
-mgas
-mmips-as
-mhalf-pic
-mno-half-pic
-membedded-pic
-mno-embedded-pic
-mabicalls
-mno-abicalls
-mmips-tfile
-mno-mips-tfile
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These machine-independent options control the interface conventions used in code generation.
Most of them have both positive and negative forms; the negative form of `-ffoo' would be `-fno-foo'. In the table below, only one of the forms is listed--the one which is not the default. You can figure out the other form by either removing `no-' or adding it.
This level of control is not really compatible with use of a bundled system like MIPS SDE. Some of the options documented here will break compatibility with the MIPS SDE libraries or other parts of the toolchain.
-fexceptions
-funwind-tables
-fexceptions
, except that it will just generate any needed
static data, but will not affect the generated code in any other way.
You will normally not enable this option; instead, a language processor
that needs this handling would enable it on your behalf.
-fpcc-struct-return
struct
and union
values in memory like
longer ones, rather than in registers. This convention is less
efficient, but it has the advantage of allowing intercallability between
GCC-compiled files and files compiled with other compilers.
The precise convention for returning structures in memory depends on the target configuration macros.
Short structures and unions are those whose size and alignment match that of some integer type.
-freg-struct-return
struct
and union
values are
returned in registers when possible. This is more efficient for small
structures than `-fpcc-struct-return'.
If you specify neither `-fpcc-struct-return' nor its contrary `-freg-struct-return', GCC defaults to whichever convention is standard for the target. If there is no standard convention, GCC defaults to `-fpcc-struct-return', except on targets where GCC is the principal compiler. In those cases, we can choose the standard, and we chose the more efficient register return alternative.
-fshort-enums
enum
type only as many bytes as it needs for the
declared range of possible values. Specifically, the enum
type
will be equivalent to the smallest integer type which has enough room.
-fshort-double
double
as for float
.
-fno-common
extern
) in
two different compilations, you will get an error when you link them.
This setting is the default for MIPS16 code generation, since it allows more efficient access to locally defined variables. If that breaks your code then you can either use the "common" attribute on individual variables (see section 3.29 Specifying Attributes of Variables), or use the positive `-fcommon' flag to override this globally.
-fno-ident
-fno-gnu-linker
collect2
program to make sure the system linker includes
constructors and destructors. (collect2
is included in the GCC
distribution.) For systems which must use collect2
, the
compiler driver gcc
is configured to do this automatically.
-finhibit-size-directive
.size
assembler directive, or anything else that
would cause trouble if the function is split in the middle, and the
two halves are placed at locations far apart in memory. This option is
used when compiling `crtstuff.c'; you should not need to use it
for anything else.
-fverbose-asm
`-fno-verbose-asm', the default, causes the extra information to be omitted and is useful when comparing two assembler files.
-fvolatile
-fvolatile-global
-fvolatile-static
-fpic
Position-independent code requires special support, and therefore works only on certain machines and operating systems.
-fPIC
Position-independent code requires special support, and therefore works only on certain machines and operating systems.
-ffixed-reg
reg must be the name of a register.
The register names accepted are machine-specific.
For MIPS they are the register number, optionally preceded by a `$'
(e.g. $4
), or the software name of the register, again optionally
preceded by a `$' (e.g. $a0
).
This flag does not have a negative form, because it specifies a three-way choice.
-fcall-used-reg
It is an error to used this flag with the frame pointer or stack pointer. Use of this flag for other registers that have fixed pervasive roles in the machine's execution model will produce disastrous results.
This flag does not have a negative form, because it specifies a three-way choice.
-fcall-saved-reg
It is an error to used this flag with the frame pointer or stack pointer. Use of this flag for other registers that have fixed pervasive roles in the machine's execution model will produce disastrous results.
A different sort of disaster will result from the use of this flag for a register in which function values may be returned.
This flag does not have a negative form, because it specifies a three-way choice.
-fpack-struct
-fcheck-memory-usage
Normally, you should compile all, or none, of your code with this option.
If you do mix code compiled with and without this option, you must ensure that all code that has side effects and that is called by code compiled with this option is, itself, compiled with this option. If you do not, you might get erroneous messages from the detector.
If you use functions from a library that have side-effects (such as
read
), you might not be able to recompile the library and
specify this option. In that case, you can enable the
`-fprefix-function-name' option, which requests GCC to encapsulate
your code and make other functions look as if they were compiled with
`-fcheck-memory-usage'. This is done by calling "stubs",
which are provided by the detector. If you cannot find or build
stubs for every function you call, you might have to specify
`-fcheck-memory-usage' without `-fprefix-function-name'.
If you specify this option, you can not use the asm
or
__asm__
keywords in functions with memory checking enabled. GNU
CC cannot understand what the asm
statement may do, and therefore
cannot generate the appropriate code, so it will reject it. However, if
you specify the function attribute no_check_memory_usage
(see
see section 3.23 Declaring Attributes of Functions, GNU CC will disable memory checking within a
function; you may use asm
statements inside such functions. You
may have an inline expansion of a non-checked function within a checked
function; in that case GNU CC will not generate checks for the inlined
function's memory accesses.
If you move your asm
statements to non-checked inline functions
and they do access memory, you can add calls to the support code in your
inline function, to indicate any reads, writes, or copies being done.
These calls would be similar to those done in the stubs described above.
-fprefix-function-name
If you compile the following code with `-fprefix-function-name'
extern void bar (int); void foo (int a) { return bar (a + 5); } |
GCC will compile the code as if it was written:
extern void prefix_bar (int); void prefix_foo (int a) { return prefix_bar (a + 5); } |
-finstrument-functions
__builtin_return_address
does not work beyond the current
function, so the call site information may not be available to the
profiling functions otherwise.)
void __cyg_profile_func_enter (void *this_fn, void *call_site); void __cyg_profile_func_exit (void *this_fn, void *call_site); |
The first argument is the address of the start of the current function, which may be looked up exactly in the symbol table.
This instrumentation is also done for functions expanded inline in other functions. The profiling calls will indicate where, conceptually, the inline function is entered and exited. This means that addressable versions of such functions must be available. If all your uses of a function are expanded inline, this may mean an additional expansion of code size. If you use `extern inline' in your C code, an addressable version of such functions must be provided. (This is normally the case anyways, but if you get lucky and the optimizer always expands the functions inline, you might have gotten away without providing static copies.)
A function may be given the attribute no_instrument_function
, in
which case this instrumentation will not be done. This can be used, for
example, for the profiling functions listed above, high-priority
interrupt routines, and any functions from which the profiling functions
cannot safely be called (perhaps signal handlers, if the profiling
routines generate output or allocate memory).
-fstack-check
Note that this switch does not actually cause checking to be done; the operating system must do that. The switch causes generation of code to ensure that the operating system sees the stack being extended.
-fstack-limit-register=reg
-fstack-limit-symbol=sym
-fno-stack-limit
For instance, if the stack starts at address `0x80000000' and grows
downwards you can use the flags
`-fstack-limit-symbol=__stack_limit'
and
`-Wl,--defsym,__stack_limit=0x7ffe0000' which will enforce a stack
limit of 128K.
-funaligned-pointers
-funaligned-struct-hack
This option makes some invalid code work at the expense of disabling some optimizations. It is strongly recommended that this option not be used.
-foptimize-comparisons
&&
and ||
expressions. This is an experimental option. In some cases it can
result in worse code. It depends on many factors. Now it is known
only that the optimization works well for PPC740 and PPC750. This
option switches on the following transformations:
(a != 0 || b != 0) => ((a | b) != 0) (a == 0 && b == 0) => ((a | b) == 0) (a != b || c != d) => (((a ^ b) | (c ^ d)) != 0) (a == b && c == d) => (((a ^ b) | (c ^ d)) == 0) (a != 0 && b != 0) => (((a | -a) & (b | -b)) < 0) (a != b && c != d) => x = a ^ b; y = c ^ d; (((x | -x) & (y | -y)) < 0) (a < 0 || b < 0) => ((a | b) < 0) (a < 0 && b < 0) => ((a & b) < 0) (a >= 0 || b >= 0) => ((a & b) >= 0) (a >= 0 && b >= 0) => ((a | b) >= 0) (a < 0 || b >= 0) => ((a | ~b) < 0) (a < 0 && b >= 0) => ((a & ~b) < 0) (a >= 0 || b < 0) => ((~a | b) < 0) (a >= 0 && b < 0) => ((~a & b) < 0) (a != 0 && b < 0) => (((a | -a) & b) < 0) (a != 0 && b >= 0) => (((a | -a) & ~b) < 0) (a < 0 && b != 0) => (((b | -b) & a) < 0) (a >= 0 && b != 0) => (((b | -b) & ~a) < 0) |
-fargument-alias
-fargument-noalias
-fargument-noalias-global
`-fargument-alias' specifies that arguments (parameters) may alias each other and may alias global storage. `-fargument-noalias' specifies that arguments do not alias each other, but may alias global storage. `-fargument-noalias-global' specifies that arguments do not alias each other and do not alias global storage.
Each language will automatically use whatever option is required by the language standard. You should not need to use these options yourself.
-fleading-underscore
Be warned that you should know what you are doing when invoking this option, and that not all targets provide complete support for it.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This section describes several environment variables that affect how GCC operates. Some of them work by specifying directories or prefixes to use when searching for various kinds of files. Some are used to specify other aspects of the compilation environment.
Note that you can also specify places to search using options such as `-B', `-I' and `-L' (see section 2.12 Options for Directory Search). These take precedence over places specified using environment variables, which in turn take precedence over those specified by the configuration of GCC.
LANG
LC_CTYPE
LC_MESSAGES
LC_ALL
LC_CTYPE
and LC_MESSAGES
if it has been configured to do
so. These locale categories can be set to any value supported by your
installation. A typical value is `en_UK' for English in the United
Kingdom.
The LC_CTYPE
environment variable specifies character
classification. GCC uses it to determine the character boundaries in
a string; this is needed for some multibyte encodings that contain quote
and escape characters that would otherwise be interpreted as a string
end or escape.
The LC_MESSAGES
environment variable specifies the language to
use in diagnostic messages.
If the LC_ALL
environment variable is set, it overrides the value
of LC_CTYPE
and LC_MESSAGES
; otherwise, LC_CTYPE
and LC_MESSAGES
default to the value of the LANG
environment variable. If none of these variables are set, GCC
defaults to traditional C English behavior.
TMPDIR
TMPDIR
is set, it specifies the directory to use for temporary
files. GCC uses temporary files to hold the output of one stage of
compilation which is to be used as input to the next stage: for example,
the output of the preprocessor, which is the input to the compiler
proper.
GCC_EXEC_PREFIX
GCC_EXEC_PREFIX
is set, it specifies a prefix to use in the
names of the subprograms executed by the compiler. No slash is added
when this prefix is combined with the name of a subprogram, but you can
specify a prefix that ends with a slash if you wish.
If GCC_EXEC_PREFIX
is not set, GNU CC will attempt to figure out
an appropriate prefix to use based on the pathname it was invoked with.
If GCC cannot find the subprogram using the specified prefix, it tries looking in the usual places for the subprogram.
The default value of GCC_EXEC_PREFIX
is
`prefix/lib/gcc-lib/' where prefix is the value
of prefix
when you ran the `configure' script.
Other prefixes specified with `-B' take precedence over this prefix.
This prefix is also used for finding files such as `crt0.o' that are used for linking.
In addition, the prefix is used in an unusual way in finding the
directories to search for header files. For each of the standard
directories whose name normally begins with `/usr/local/lib/gcc-lib'
(more precisely, with the value of GCC_INCLUDE_DIR
), GCC tries
replacing that beginning with the specified prefix to produce an
alternate directory name. Thus, with `-Bfoo/', GCC will search
`foo/bar' where it would normally search `/usr/local/lib/bar'.
These alternate directories are searched first; the standard directories
come next.
COMPILER_PATH
COMPILER_PATH
is a colon-separated list of
directories, much like PATH
. GCC tries the directories thus
specified when searching for subprograms, if it can't find the
subprograms using GCC_EXEC_PREFIX
.
LIBRARY_PATH
LIBRARY_PATH
is a colon-separated list of
directories, much like PATH
. When configured as a native compiler,
GCC tries the directories thus specified when searching for special
linker files, if it can't find them using GCC_EXEC_PREFIX
. Linking
using GCC also uses these directories when searching for ordinary
libraries for the `-l' option (but directories specified with
`-L' come first).
C_INCLUDE_PATH
CPLUS_INCLUDE_PATH
OBJC_INCLUDE_PATH
PATH
. When GCC searches for header files, it tries the
directories listed in the variable for the language you are using, after
the directories specified with `-I' but before the standard header
file directories.
DEPENDENCIES_OUTPUT
The value of DEPENDENCIES_OUTPUT
can be just a file name, in
which case the Make rules are written to that file, guessing the target
name from the source file name. Or the value can have the form
`file target', in which case the rules are written to
file file using target as the target name.
LANG
LANG
are recognized:
C-JIS
C-SJIS
C-EUCJP
If LANG
is not defined, or if it has some other value, then the
compiler will use mblen and mbtowc as defined by the default locale to
recognize and translate multibyte characters.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The program protoize
is an optional part of GNU C. You can use
it to add prototypes to a program, thus converting the program to ANSI
C in one respect. The companion program unprotoize
does the
reverse: it removes argument types from any prototypes that are found.
When you run these programs, you must specify a set of source files as command line arguments. The conversion programs start out by compiling these files to see what functions they define. The information gathered about a file foo is saved in a file named `foo.X'.
After scanning comes actual conversion. The specified files are all eligible to be converted; any files they include (whether sources or just headers) are eligible as well.
But not all the eligible files are converted. By default,
protoize
and unprotoize
convert only source and header
files in the current directory. You can specify additional directories
whose files should be converted with the `-d directory'
option. You can also specify particular files to exclude with the
`-x file' option. A file is converted if it is eligible, its
directory name matches one of the specified directory names, and its
name within the directory has not been excluded.
Basic conversion with protoize
consists of rewriting most
function definitions and function declarations to specify the types of
the arguments. The only ones not rewritten are those for varargs
functions.
protoize
optionally inserts prototype declarations at the
beginning of the source file, to make them available for any calls that
precede the function's definition. Or it can insert prototype
declarations with block scope in the blocks where undeclared functions
are called.
Basic conversion with unprotoize
consists of rewriting most
function declarations to remove any argument types, and rewriting
function definitions to the old-style pre-ANSI form.
Both conversion programs print a warning for any function declaration or definition that they can't convert. You can suppress these warnings with `-q'.
The output from protoize
or unprotoize
replaces the
original source file. The original file is renamed to a name ending
with `.save' (for DOS, the saved filename ends in `.sav'
without the original `.c' suffix). If the `.save' (`.sav'
for DOS) file already exists, then the source file is simply discarded.
protoize
and unprotoize
both depend on GCC itself to
scan the program and collect information about the functions it uses.
So neither of these programs will work until GCC is installed.
Here is a table of the options you can use with protoize
and
unprotoize
. Each option works with both programs unless
otherwise stated.
-B directory
protoize
.
-c compilation-options
gcc
to
produce the `.X' files. The special option `-aux-info' is
always passed in addition, to tell gcc
to write a `.X' file.
Note that the compilation options must be given as a single argument to
protoize
or unprotoize
. If you want to specify several
gcc
options, you must quote the entire set of compilation options
to make them a single word in the shell.
There are certain gcc
arguments that you cannot use, because they
would produce the wrong kind of output. These include `-g',
`-O', `-c', `-S', and `-o' If you include these in
the compilation-options, they are ignored.
-C
protoize
.
-g
protoize
.
-i string
protoize
.
unprotoize
converts prototyped function definitions to old-style
function definitions, where the arguments are declared between the
argument list and the initial `{'. By default, unprotoize
uses five spaces as the indentation. If you want to indent with just
one space instead, use `-i " "'.
-k
-l
protoize
with `-l' inserts
a prototype declaration for each function in each block which calls the
function without any declaration. This option applies only to
protoize
.
-n
-N
-p program
-q
-v
gcc
.
If you need special compiler options to compile one of your program's
source files, then you should generate that file's `.X' file
specially, by running gcc
on that source file with the
appropriate options and the option `-aux-info'. Then run
protoize
on the entire set of files. protoize
will use
the existing `.X' file because it is newer than the source file.
For example:
gcc -Dfoo=bar file1.c -aux-info protoize *.c |
You need to include the special files along with the rest in the
protoize
command, even though their `.X' files already
exist, because otherwise they won't get converted.
See section 6.7 Caveats of using protoize
, for more information on how to use
protoize
successfully.
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |